lst = input().split()
dicts = {}
max = 0
for i in lst:
if i in dicts:
dicts[i] += 1
else:
dicts[i] = 1
if dicts[i] > max:
max = dicts[i]
if max == 3:
print(0)
elif max == 2:
print(1)
else:
max = 0
for i in range(2):
for j in range(i + 1, 3):
if lst[i][1] == lst[j][1] and abs(ord(lst[i][0]) - ord(lst[j][0])) < 3:
max += 1
if max == 0:
print(2)
elif max > 0 and max < 3:
print(1)
else:
print(0)
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
typedef unsigned int ui;
typedef long double ld;
typedef pair<int, int> ii;
typedef pair<int, ii> iii;
typedef pair<ll, ll> pll;
typedef pair<ll, ii> pli;
typedef vector<int> vi;
typedef vector<ll> vll;
#define fi first
#define se second
const int INF = 1e9;
const ll LINF = 1e18;
const ll MOD = 1e9 + 7;
const double EPS = 1e-9;
const int N = 1e4;
int f[127][10];
void solve() {
string a, b, c;
cin >> a >> b >> c;
f[a[1]][a[0]-'0']++;
f[b[1]][b[0]-'0']++;
f[c[1]][c[0]-'0']++;
int mx = 0;
int p[3] = {'m', 'p', 's'};
for(int i = 0; i < 3; i++) {
for(int j = 1; j <= 9; j++) {
mx = max(mx, f[p[i]][j]);
}
}
for(int i = 0; i < 3; i++) {
for(int j = 3; j <= 9; j++) {
mx = max(mx, (f[p[i]][j]!= 0)+(f[p[i]][j-1] != 0)+(f[p[i]][j-2] != 0));
}
}
cout << 3 - mx << "\n";
}
int main() {
ios::sync_with_stdio(false); cin.tie(nullptr);
int T = 1;
//cin >> T;
for(int i = 1; i <= T; i++) {
//cout << "Case #" << i << ":\n";
solve();
}
return 0;
}
99A - Help Far Away Kingdom | 622B - The Time |
1688C - Manipulating History | 1169D - Good Triple |
1675B - Make It Increasing | 588A - Duff and Meat |
1541B - Pleasant Pairs | 1626B - Minor Reduction |
1680A - Minimums and Maximums | 1713A - Traveling Salesman Problem |
1713B - Optimal Reduction | 1710A - Color the Picture |
1686B - Odd Subarrays | 251A - Points on Line |
427C - Checkposts | 1159A - A pile of stones |
508A - Pasha and Pixels | 912A - Tricky Alchemy |
1249A - Yet Another Dividing into Teams | 1713C - Build Permutation |
1699A - The Third Three Number Problem | 1617B - GCD Problem |
841A - Generous Kefa | 1690B - Array Decrements |
1692C - Where's the Bishop | 104A - Blackjack |
1438A - Specific Tastes of Andre | 1711C - Color the Picture |
1194C - From S To T | 110B - Lucky String |